package com.example.smartcity.ui.Adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.smartcity.R;
import com.example.smartcity.ui.Bean.StopHistoryBean;

import java.util.ArrayList;
import java.util.List;

public class HistoryRECAdapter extends RecyclerView.Adapter<HistoryRECAdapter.MyViewHolder> {

    private Context context;
    private int Resource;
    private List<StopHistoryBean.RowsBean> list;
    public HistoryRECAdapter(Context context, int Resource, List<StopHistoryBean.RowsBean> list){
        this.context = context;
        this.Resource = Resource;
        this.list = list;
    }
    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(context).inflate(Resource,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        Log.d("TAG", "onBindViewHolder: "+list.size());
        holder.TVEntryTime.setText(list.get(position).getEntryTime());
        holder.TVOutTime.setText(list.get(position).getOutTime());
        holder.TVHparkName.setText(list.get(position).getParkName());
        holder.TVPlateNumber.setText(list.get(position).getPlateNumber());
        holder.TVMonetary.setText(list.get(position).getMonetary());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    class MyViewHolder extends RecyclerView.ViewHolder{
        private TextView TVPlateNumber;
        private TextView TVMonetary;
        private TextView TVEntryTime;
        private TextView TVOutTime;
        private TextView TVHparkName;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            TVPlateNumber = itemView.findViewById(R.id.TV_plateNumber);
            TVMonetary = itemView.findViewById(R.id.TV_monetary);
            TVEntryTime = itemView.findViewById(R.id.TV_entryTime);
            TVOutTime = itemView.findViewById(R.id.TV_outTime);
            TVHparkName = itemView.findViewById(R.id.TV_HparkName);
        }
    }

}
